package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入你要归还的书名：");
        String name = scanner.nextLine();
        int CurrentSide = bookList.getUseSide();
        for (int i = 0; i < CurrentSide; i++) {
            Book book = bookList.getBooks(i);
            if (book.getName().equals(name)){
                if (book.isBorrowed() == true){
                    book.setBorrowed(false);
                    System.out.println("归还成功！");
                }
                return;
            }
        }
        System.out.println("那么书架上应该是没有你要归还的图书！");
    }
}
